<%-- 
    Document   : suksesupload
    Created on : Dec 10, 2012, 12:57:05 PM
    Author     : Angga Dinata
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
            bean.DataBaseConnection conn = new bean.DataBaseConnection ();
%>

<jsp:useBean id="mobil" scope="session" class="kontrol.mobil"/>

<%@ page import="java.io.*" %>
<%@ page import="com.oreilly.servlet.MultipartRequest" %>
<%@page import="java.util.ArrayList"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <%
            ArrayList<kontrol.mobil> vmobil = new kontrol.Proses().getDisplay();
%>
<%
            String contentType = request.getContentType();
            if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0)) {
                MultipartRequest mr = new MultipartRequest(request, request.getRealPath("./Mobil"), 1024 * 1024 * 1024);
                mobil.setNamamobil(mr.getParameter("namamobil"));
                mobil.setHarga(mr.getParameter("harga"));
                mobil.setPemilik(mr.getParameter("pemilik"));
             
                mobil.setGambar("./Mobil/" + mr.getOriginalFileName("gambar"));
            }
%>
        <%
            try {
                String query = "INSERT INTO MOBIL(namamobil, harga, pemilik, gambar) VALUES "
                        + "('" + mobil.getNamamobil() + "' , '"+ mobil.getHarga() + "' , '" + mobil.getPemilik()
                        + "' , '" + mobil.getGambar()+ "')";
                java.sql.Statement statement = conn.getConnection().createStatement();
                int s = statement.executeUpdate(query);

                System.out.println("Data berhasil dimasukkan \n"+mobil.getNamamobil());

                statement.close();
            } catch (Exception ex) {
                out.println("message1: " + ex.getMessage());
            }
%>
    </head>
    <body>
        <h1>Data mobil yang dimasukkan berhasil !</h1>
        <FORM ENCTYPE="multipart/form-data" ACTION="garasimobil2.jsp" METHOD=POST>
            <br>
            <table border="">
                <thead>
                    <tr>
                        <th colspan="2"><p align="right"><INPUT TYPE="submit" VALUE="OK" ></p> </th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td></td>
                    </tr>
                </tbody>
            </table>

            <tr><td 
        </Form>
    </body>
</html>
